package com.controller.backend;

import com.biz.OperationLogBiz;
import com.core.Result;
import com.core.ResultGenerator;
import com.entity.model.OperationLog;
import com.github.pagehelper.PageInfo;
import com.util.webpage.PageData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by jc on 2023/03/14.
 */
@Controller
@RequestMapping("/backend/security/operationLog")
public class OperationLogController extends BaseController<OperationLog> {
    @Autowired
    private OperationLogBiz operationLogBiz;

    @RequestMapping(value = "index")
    public String index() throws Exception {
        return "/backend/security/operationLog/list";
    }

    @RequestMapping(value = "/opList")
    @ResponseBody
    public Result opList(HttpServletRequest request) {
        PageData cond = new PageData(request);
        List<OperationLog> operationLogs = operationLogBiz.getOpList(cond);
        PageInfo<OperationLog> pageInfo = new PageInfo<OperationLog>(operationLogs);
        Integer total = (int) pageInfo.getTotal();
        return ResultGenerator.genSuccessResult(operationLogs, total);
    }
}
